package activity

import (
	"net/http"
	"github.com/gin-gonic/gin"
	"github.com/whencome/xlog"
	"gitee.com/zhanglibin/spike/conf"
	activityModel "gitee.com/zhanglibin/spike/model/activity"
	// activityDao "gitee.com/zhanglibin/spike/dao/activity"
)

type ActivityInfoRequestParam struct {
	Id int `json:"id" binding:"required"`
}

type ActivityInfoRespone struct {
	Code int `json:"code"`
	Msg  string `json:"msg"`
	Data interface{} `json:"data,omitempty"`
}

func Demo(c *gin.Context) {
	xlog.Info("succsss")
	xlog.Info(conf.C.Mysql)
	c.JSON(http.StatusOK, "SUCCESS")
}

func ActivityInfo(c *gin.Context) {
	var param ActivityInfoRequestParam
	err := c.ShouldBind(&param)
	if err != nil {
		// msg := c.GetValidatedErrorField(err)
		c.JSON(http.StatusOK, ActivityInfoRespone{Code: 500, Msg: err.Error()})
		return
	} 

	result, err := activityModel.GetActivityInfo(param.Id)
	if err != nil {
		c.JSON(http.StatusOK, ActivityInfoRespone{Code: 500, Msg: err.Error()})
		return
	}
	c.JSON(http.StatusOK, ActivityInfoRespone{Code: 200, Msg: "success",Data: result})
	return
}